<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>while do...while验证用户名和密码</title>
</head>
<body>
    <script>
        var user= prompt('请输入用户名');
        var password= prompt('请输入密码');
        while(user !='admin' || password != '123456'){
            alert('用户名或密码有误');
            user =prompt('请输入用户名');
            password =prompt('请输入密码');
        }
        alert('登录成功');
        /* 
        do{
            alert('用户名或密码有误');
            var user= prompt('请输入用户名');
            var password= prompt('请输入密码');
        }while(user !='admin' || password != '123456')
        alert('登录成功');
        */
    </script>
</body>
</html>